refactor: use text cases to convert to title case#374
Merged
Conversation
Signed-off-by: Bruno De Assis Marques <bruno.marques@swirldslabs.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request refactors the display name formatting in the hardware package to use the standard golang.org/x/text/cases library instead of a custom capitalize function. This improves code maintainability and provides more robust Unicode handling while maintaining identical behavior for existing node types and profiles.
Changes:
- Replaced custom
capitalizefunction withcases.Title(language.Und)from the standard text/cases library - Added imports for
golang.org/x/text/casesandgolang.org/x/text/language - Simplified
formatDisplayNameto use the standard library caser
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This pull request updates the
node_spec.gofile in thehardwarepackage to improve how display names are formatted. The main change is replacing the customcapitalizefunction with a more robust title-casing approach using thegolang.org/x/text/casespackage.Formatting improvements:
capitalizefunction with thecases.Titlefunction from thegolang.org/x/text/casespackage informatDisplayName, ensuring proper title-casing for node type and profile names.golang.org/x/text/casesandgolang.org/x/text/languageto support the new title-casing functionality.Related Issues